﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Platform.ObjectModel.Design;

namespace Platform.ObjectModel.Rules.Numbers
{
	/// <summary>
	/// 
	/// </summary>
	public class OnlyPositiveValues : RuleBase
	{
		public static readonly DataObjectName Name = DataObjectName.From( typeof( OnlyPositiveValues ) );

		public OnlyPositiveValues()
			: base( Name )
		{ }

		public override bool Validate( dynamic value, DocumentContext context )
		{
			FieldType type = LibraryUtility.GetFieldType( value );
			if ( type == FieldType.Number )
				return ( ( double )value ) > 0;
			else
				return false;
		}
	}
}
